<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\UserGroup;

/* @var $this yii\web\View */
/* @var $model common\models\GoodsExtra */
/* @var $form yii\widgets\ActiveForm */
$js = "
var package_url = '". \yii\helpers\Url::toRoute(['goods-extra/get-package']) ."'
";

?>

<div class="box-body">
    
    <?php $form = ActiveForm::begin([
        'options'=>['class'=>'form-horizontal'],
        'fieldConfig'=>[
            'template'=>"{label}\n<div class=\"col-sm-10\">{input}\n{hint}\n{error}</div>",
            'labelOptions'=>['class'=>'col-sm-2 control-label'],
        ],
    ]); ?>
    
    <?= $form->field($model, 'goods_id')->dropDownList(ArrayHelper::map(\common\models\Goods::findList(), 'goods_id', 'goods_name')) ?>
    
    <?= $form->field($model, 'group_id')->dropDownList(ArrayHelper::map(UserGroup::findList(), 'group_id', 'group_name')) ?>
    
    <?= $form->field($model, 'package_id')->dropDownList([]) ?>
    
    <?= $form->field($model, 'sale')->textInput() ?>
    

    <div class="box-footer">
        <a href="javascript:history.back();" class="btn btn-default">取消</a>
        <?= Html::submitButton($model->isNewRecord ? '创建' : '更新', ['class' => $model->isNewRecord ? 'btn btn-success pull-right' : 'btn btn-primary pull-right']) ?>
    </div>
    
    <?php ActiveForm::end(); ?>
    
    <?php
        $this->registerJs($js, \yii\web\View::POS_HEAD)
    ?>
    <?php $this->registerJsFile('@web/js/goods-extra.js', ['depends' => 'backend\assets\AdminLtePluginAsset']) ?>
</div>


